package com.zrx.springboot.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zrx.springboot.entity.Admin;

import com.zrx.springboot.mapper.AdminMapper;
import com.zrx.springboot.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;

@Service
@Transactional(propagation = Propagation.REQUIRES_NEW)
public class AdminSerbiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    @Override
    public void update(Integer id, Timestamp date) {
        adminMapper.update(id,date);
    }

    @Override
    public void upword(Integer id, String password) {
        adminMapper.upword(id,password);
    }

    @Override

    public String checkadmin(String adminname) {
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("adminname", adminname);
        Admin admin = adminMapper.selectOne(queryWrapper);
        if (admin == null) {
            return "101";
            //用户名不存在
        } else {
            return "102";
            //用户名已存在
        }
    }
}
